package com.ruoyi.zxjd.exposure.controller;

import java.util.List;

import com.ruoyi.zxjd.exposure.domain.ExposureArrange;
import com.ruoyi.zxjd.exposure.service.IExposureArrangeService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zxjd.exposure.domain.ExposureProgress;
import com.ruoyi.zxjd.exposure.service.IExposureProgressService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 查看进度Controller
 * 
 * @author lcc
 * @date 2021-02-07
 */
@Controller
@RequestMapping("/exposure/progress")
public class ExposureProgressController extends BaseController
{
    private String prefix = "exposure/progress";

    @Autowired
    private IExposureProgressService exposureProgressService;

    @Autowired
    private IExposureArrangeService exposureArrangeService;

    @RequiresPermissions("exposure:progress:view")
    @GetMapping()
    public String progress()
    {
        return prefix + "/progress";
    }

    /**
     * 查询查看进度列表
     */
    @RequiresPermissions("exposure:progress:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ExposureProgress exposureProgress)
    {
        startPage();
        List<ExposureProgress> list = exposureProgressService.selectExposureProgressList(exposureProgress);
        return getDataTable(list);
    }

    /**
     * 导出查看进度列表
     */
    @RequiresPermissions("exposure:progress:export")
    @Log(title = "查看进度", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ExposureProgress exposureProgress)
    {
        List<ExposureProgress> list = exposureProgressService.selectExposureProgressList(exposureProgress);
        ExcelUtil<ExposureProgress> util = new ExcelUtil<ExposureProgress>(ExposureProgress.class);
        return util.exportExcel(list, "progress");
    }

    /**
     * 新增查看进度
     */
    @GetMapping("/add")
    public String add(ModelMap mmap)
    {
        ExposureArrange exposureArrange = new ExposureArrange();
        exposureArrange.setStatus("1");
        List<ExposureArrange> exposureArranges = exposureArrangeService.selectExposureArrangeList(exposureArrange);
        mmap.put("exposureArranges",exposureArranges);
        return prefix + "/add";
    }

    /**
     * 新增保存查看进度
     */
    @RequiresPermissions("exposure:progress:add")
    @Log(title = "查看进度", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ExposureProgress exposureProgress)
    {
        return toAjax(exposureProgressService.insertExposureProgress(exposureProgress));
    }

    /**
     * 修改查看进度
     */
    @GetMapping("/edit/{progressId}")
    public String edit(@PathVariable("progressId") Long progressId, ModelMap mmap)
    {
        ExposureProgress exposureProgress = exposureProgressService.selectExposureProgressById(progressId);
        mmap.put("exposureProgress", exposureProgress);
        return prefix + "/edit";
    }

    /**
     * 修改保存查看进度
     */
    @RequiresPermissions("exposure:progress:edit")
    @Log(title = "查看进度", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ExposureProgress exposureProgress)
    {
        return toAjax(exposureProgressService.updateExposureProgress(exposureProgress));
    }

    /**
     * 删除查看进度
     */
    @RequiresPermissions("exposure:progress:remove")
    @Log(title = "查看进度", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(exposureProgressService.deleteExposureProgressByIds(ids));
    }
}
